package com.handu.luna.core.domain.promotion;

import com.handu.luna.core.domain.BasePersistentDomain;
import com.handu.luna.core.domain.user.User;

import javax.persistence.Entity;
import javax.persistence.PostLoad;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by wangzailiang on 2014/8/5.
 */
@Entity
public class CashCardLog extends BasePersistentDomain<CashCardLog> {

    private Long cashCardId;
    private Long userId;
    private Date useDate;
    private Long orderId;
    private Long orderCode;
    private BigDecimal usePrice;
    private BigDecimal thisLeft;

    @Transient CashCard cashCard;
    @Transient User user;

    @PostLoad
    public void init() {
        if(null != cashCardId) {
            cashCard = context.getCashCardRepository().findOne(cashCardId);
        }
        if(null != userId) {
            user = context.getUserRepository().findOne(userId);
        }

    }

    public Long getCashCardId() {
        return cashCardId;
    }

    public void setCashCardId(Long cashCardId) {
        this.cashCardId = cashCardId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Date getUseDate() {
        return useDate;
    }

    public void setUseDate(Date useDate) {
        this.useDate = useDate;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getOrderCode() {
        return orderCode;
    }

    public void setOrderCode(Long orderCode) {
        this.orderCode = orderCode;
    }

    public BigDecimal getUsePrice() {
        return usePrice;
    }

    public void setUsePrice(BigDecimal usePrice) {
        this.usePrice = usePrice;
    }

    public BigDecimal getThisLeft() {
        return thisLeft;
    }

    public void setThisLeft(BigDecimal thisLeft) {
        this.thisLeft = thisLeft;
    }

    public CashCard getCashCard() {
        return cashCard;
    }

    public void setCashCard(CashCard cashCard) {
        this.cashCard = cashCard;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
